import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/purchase/receipts_stock/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(new Error(res.data.msg));
}
//添加货品
export async function add_goods(params) {
  const res = await request.post('/purchase/receipts_stock/add_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 删除货品 */
export async function del_goods(params) {
  const res = await request.post('/purchase/receipts_stock/del_goods', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 总部返厂批量录入 */
export async function batch_enter(params) {
  const res = await request.post(
    '/purchase/receipts_stock/batch_enter',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 详情 */
export async function goods_detail(params) {
  const res = await request.post('/purchase/receipts_stock/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 分配到货详情 */
export async function receipts_stock_detail(params) {
  const res = await request.post('/purchase/receipts_stock/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
// 接收分配单(进货)
export async function receipts_stock_confirm_receive(params) {
  const res = await request.post(
    '/purchase/receipts_stock/confirm_receive',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
// 柜组下拉
export async function store_group_select(params) {
  const res = await request.post('/material/store_group/get_list', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
// 门店下拉
export async function store_get_list(params) {
  const res = await request.post('/tenant/store/get_list', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
